#define _CRT_SECURE_NO_WARNINGS
int TreeSize(struct TreeNode* root)
{
    if (root == NULL)
    {
        return 0;
    }
    return TreeSize(root->left) + TreeSize(root->right) + 1;
}
void preorder(struct TreeNode* root, int* arr, int* i)
{
    if (root == NULL)
    {
        return;
    }
    preorder(root->left, arr, i);
    arr[(*i)++] = root->val;
    preorder(root->right, arr, i);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize)
{
    int i = 0;
    *returnSize = TreeSize(root);
    int* arr = (int*)malloc(*returnSize * sizeof(int));
    preorder(root, arr, &i);
    return arr;
}